package com.nervenets.web.annotation;


import com.nervenets.web.validation.Type;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @author Joe create 2009-1-2 13:20:16
 * @link {http://www.nervenets.com}
 * @copyright YunKing Union
 */
@Retention(RetentionPolicy.RUNTIME)

/**
 * The annotation can be added to both class definition and field declaration.
 * The validator must be set if it is for class definition. 
 */
@Target({ElementType.TYPE, ElementType.FIELD})
public @interface NeedValidation {
    /**
     * To determine this class or this field need to be validated.
     *
     * @return <code>true</code> if needed ,otherwise <code>false</code>
     */
    boolean value() default true;

    /**
     * The validator should only exist for ElementType.TYPE which is to determine
     * a class need to be validated.
     *
     * @return
     */
    String validator() default "";

    String description() default "";

    /**
     * Unique is to mark if the field need to be unique or not.
     * Should only exist in field.
     *
     * @return
     */
    boolean unique() default false;

    Type type();
}
